package shawn.projection;

import java.io.Serializable;

/**
 * 图块坐标点
 * @author zhangzuoqiang
 * @date 2015年8月20日 上午10:07:57
 */
public class TilePoint implements Serializable {

  private static final long serialVersionUID = -3672865664164075574L;

  public int x;
  public int y;

  public TilePoint(int x, int y) {
    this.x = x;
    this.y = y;
  }

  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (!(o instanceof TilePoint)) {
      return false;
    }
    final TilePoint t = (TilePoint) o;
    if (x == t.x && y == t.y) {
      return true;
    } else {
      return false;
    }
  }

  public String toString() {
    return x + "," + y;
  }

  public static String getCNMeshPath(int level, int tileX, int tileY) {
    String r;
    if (level <= 6) {
      r = level + "";
    } else {
      int scale = (int) Math.round(Math.pow(2, level - 5));
      r = level + "/R" + (tileY / scale) + "/C" + (tileX / scale);
    }
    return r;
  }

  public static String getCNMeshFile(int level, int tileX, int tileY) {
    return level + "-" + tileX + "-" + tileY + ".png";
  }

}
